<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
  const httpUrlStr = 'https://www.whatever.com?name=zhangsan&age=18&city=%E4%B8%AD';
  function urlToObj(url) {
    const r = url.split('?')[1].split(/=|&/)
    const o = {}
    for(let i = 0; i < r.length; i += 2) o[r[i]] = decodeURIComponent(r[i+1])
    return o
  }
  console.log(urlToObj(httpUrlStr));
  </script>
</body>
</html>